﻿using System;
using System.Web;

namespace BaoJian
{
    public partial class Col : System.Web.UI.Page
    {
        string columnID;
        public string ColumnName;
        string Region = (HttpContext.Current.Request.Cookies["region"] == null || HttpContext.Current.Request.Cookies["region"].Value == "") ? "beijing" : HttpContext.Current.Request.Cookies["region"].Value;
        protected void Page_Load(object sender, EventArgs e)
        {
           try
           {
              columnID = HttpContext.Current.Request.QueryString["p"];
              if (Region == "beijing")   //若是北京站点
              {
                 LocalHeader1.Visible = false;
                 Header1.Visible = true;
              }
              else                     //若是其他站点
              {
                 LocalHeader1.Visible = true;
                 Header1.Visible = false;
              }
              if (columnID == null)
              {
                 HttpContext.Current.Response.Redirect("default.aspx");
              }
              //if (!Page.IsPostBack)
              //{
              LYQ.BLL.SysObj bll = new LYQ.BLL.SysObj();
              LYQ.Model.SysObj model = bll.GetModel(columnID);
              ColumnName = model.OName;
              BindColNews();
              //}
              //else
              //{
              //}
           }
           catch { }
        }

        private void BindColNews()
        {
            LYQ.BLL.RelatedColumn bllCol = new LYQ.BLL.RelatedColumn();
            LYQ.BLL.RelateImage bllImg = new LYQ.BLL.RelateImage();


            LYQ.Model.RelatedColumn modelCol = bllCol.GetModel("col.aspx", columnID, Region);
            //if (modelCol == null)
            //{
            //    HttpContext.Current.Response.Redirect("default.aspx");
            //}
            LYQ.Model.RelateImage modelImg = bllImg.GetModel("col.aspx", columnID, Region);        
            //if (modelImg == null)
            //{
            //    HttpContext.Current.Response.Redirect("default.aspx");
            //}

            colnews1.ColumnID = modelCol.AuxiColumnID1;
            colnews1.Region = Region;
            colnews2.ColumnID = modelCol.AuxiColumnID2;
            colnews2.Region = Region;
            colnews3.ColumnID = modelCol.AuxiColumnID3;
            colnews3.Region = Region;
            colnews4.ColumnID = modelCol.AuxiColumnID4;
            colnews4.Region = Region;
            NewsList1.Region = Region;

            string path = @"/uploads/ad/" + Region + @"/";

            ColImg1.Src = path + modelImg.ImagePath1;
            ColImg1.Region = Region;
            ColImg1.URL = modelImg.URL1;
            ColImg2.Src = path + modelImg.ImagePath2;
            ColImg2.Region = Region;
            ColImg2.URL = modelImg.URL2;
            ColImg3.Src = path + modelImg.ImagePath3;
            ColImg3.Region = Region;
            ColImg3.URL = modelImg.URL3;
            ColImg4.Src = path + modelImg.ImagePath4;
            ColImg4.Region = Region;
            ColImg4.URL = modelImg.URL4;
            ColImg5.Src = path + modelImg.ImagePath5;
            ColImg5.Region = Region;
            ColImg5.URL = modelImg.URL5;
        }

    }

    
}
